#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>

void hdfunc(int sig);

int main()
{
	signal( 2, hdfunc);	// unreliable signal
	signal(15, hdfunc);

	//signal(35, hdfunc);	// reliable signal
	//signal(36, hdfunc);

	/* signal block */
	sigset_t set;		// char str[11]
	sigemptyset(&set);	// memset(str, 0, sizeof(str));
	sigaddset(&set,15);
	sigprocmask(SIG_BLOCK, &set, NULL);
	/* signal block */
	

	for(int ii=1; ii < 100; ii++)
	{
		printf("ii=%d\n", ii);
		sleep(1);
		
		/* signal unblock */
		if(ii > 20) sigprocmask(SIG_UNBLOCK, &set, NULL);
		/* signal unblock */
	}

	return 0;
}

void hdfunc(int sig)
{
	printf("sig=%d\n", sig);

	for(int jj=1; jj<=5; jj++)
	{
		printf("jj(%d)=%d\n", sig, jj);
		sleep(1);
	}
}
